package com.example.demo.service.people;

import com.example.demo.dao.people.ProviderDAO;
import com.example.demo.model.people.Provider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProviderService {
    @Autowired
    private ProviderDAO dao;

//    public List<Provider> getByProviderId(Integer id){return dao.getByProviderId(id);}

    //查询全部
    public List<Provider> selectAll() {
        return dao.selectAll();
    }

    //增加
    public Integer addProvider(Provider provider) {
        return dao.addProvider(provider);
    }

    //删除
    public Integer deleteById(Integer id) {
        return dao.deleteById(id);
    }

    //修改
    public Integer updateById(Provider provider) {
        return dao.updateById(provider);
    }

    //    模糊查询
    public List<Provider> findProvider(String providername, String connectionperson, String phone) {
        return dao.findProvider(providername, connectionperson, phone);
    }

    ;

    public Boolean save(Provider provider) {
        Boolean flag = false;

        if (provider.getId() != null) {
            flag = dao.updateById(provider) == 1;
        } else {
            flag = dao.addProvider(provider) == 1;
        }

        return flag;
    }

}
